<%@ page contentType="text/html;charset=utf-8" 
	import="com.zh.House,java.util.*"
%>
<%
	List<House> list = (List<House>)request.getAttribute("userlist");
%>
<html>
  <head>
    <title>房屋信息管理</title>
    <link rel=stylesheet href="css/general.css" type="text/css">
    <script language="JavaScript" src="script/com.js"></script>
    <script language="JavaScript">
      function check(){
      	var key = document.all.keywords.value.trim();
      	if(key==""){
			alert("关键字为空,请重新输入!!!");
			return;
      	}
      	document.all.smf.submit();
      }
      function checkPage(temp){
      	var page = document.all.page.value.trim();
  		var reg = /^[1-9][0-9]*$/;
		if((reg.test(page.trim()))&&(page<=temp)){
			document.all.mf.submit();
		}
		else{
			alert("输入不合法,请重新输入!!!");
			return;
		}
      }
    </script>
     <style>
	       .mima {
	       width:100%;
	       height:40px;
	       background-color:#ADD8E6;
	       }
	       .zi {
	       font-size:20px;
	       position:relative;
	       left:45%;
	       margin-left:-30px;
	       line-height:40px;
	       }
	</style> 
  </head>
  <body>
  	<jsp:useBean id="userBean" class="com.zh.UserBean" scope="session"/>
	<div class="mima"><font class="zi">房屋信息管理</font></div>
	<div>
	<form action="SuperServlet" method="post" id="smf">
		<table height="20px">
		  <tr>
		    <td>
		      <input name="keywords" id="keywords" value="请输入要搜索的房屋编号"  size="28"	onfocus="document.all.keywords.value=''"/>		    
		    </td>
		    <td >
		    <input type="button" value="搜索" id="mg"  style="cursor:hand" onclick="JavaScript:check()"/>
		    </td>
	   		  <td align="center" width="90"><a href="addhouse.jsp" target="rightFrame"><font color="black" size="2">添加房屋</font></a></td>
	   		  <td>
	   		   <input type="hidden" name="action" value="looksearch" />
	           <input type="hidden" name="type" value="house"/>
	   		  </td>
		  </tr>
		</table>
	</form>
	</div>
	<% 
		if(list.isEmpty()){
			out.println("<br/><br/><br/><center><h2>没有搜索到你要找的类别!!!</h2></center>");
		}
		else{
	 %>
	<table width="98%" border="0" cellspacing="1" bgcolor="#000000" align="center" class="update">
	  <tr bgcolor="#ADD8E6" align="center">
	    <th>房屋编号</th>
	    <th>房屋地址</th>
	    <th>房屋面积</th>
	  	<th>查看/修改</th>
	  	<th>删除</th>
	  </tr>
	  <%
	  	int i = 0;
		for(House gci:list){
		if(i%2==0){
			i++;
			out.println("<tr bgcolor='white' align='center'>");
		}
		else{
			i++;
			out.println("<tr bgcolor='#ADD8E6' align='center'>");
		}
	   %>
	     <td><%= gci.getHouseId() %></td>
	     <td><%= gci.getHouseaddress() %></td>
	     <td><%= gci.getHousesquare() %></td>
	   	 <td><a href="SuperServlet?action=seekhouse&hId=<%= gci.getHouseId() %>"><img border="0" src="img/mod.gif"/>查看/修改</a></td>
	   	 <td><a href="JavaScript:del('SuperServlet?action=delhouse&hId=<%= gci.getHouseId() %>')"><img border="0" src="img/del.gif"/>删除</a></td>
	   </tr>
	  <% 
	  	}
	   %>
	</table>
	<table width="98%" align="center">
	<form method="post" action="SuperServlet" id="mf">
	  <tr>
	    <td align="left">
	      <font size="2">共<%= userBean.getCountpage() %>页&nbsp;&nbsp;当前页:<%= userBean.getCurrentpage() %></font>
	    </td>
	    <td align="right">
	      <% 
	      	if(userBean.getCurrentpage()>1){
	       %>
	       <a href="SuperServlet?action=changePage&pagename=/houseManage.jsp&page=<%= userBean.getCurrentpage()-1 %>" target="rightFrame"><img src="img/prev.gif" border="0"/></a>
	      <% 
	      	}
	      	if(userBean.getCurrentpage()<userBean.getCountpage()){
	       %>	       
	      <a href="SuperServlet?action=changePage&pagename=/houseManage.jsp&page=<%= userBean.getCurrentpage()+1 %>" target="rightFrame"><img src="img/next.gif" border="0"/></a>
	      <% 
	      	}
	      	else{
	      		out.println("<img src='img/next.gif' style='visibility:hidden'/>");
	      	}
	       %>
	      <font size="2">第<input name="page" id="page" size="2" value="<%= userBean.getCurrentpage() %>" onfocus="document.all.page.value=''"/>页</font>
	      <input type="hidden" name="action" value="changePage" />
	      <input type="hidden" name="pagename" value="/houseManage.jsp"/>
	    </td>
	    <td width="10">
	      <input type="button" value="跳转" style="cursor:hand" onclick="JavaScript:checkPage(<%= userBean.getCountpage() %>)"></button>
	    </td>
	  </tr>	
	</form>
	</table>
	<% 
		}
	 %>
  </body>
</html>